GITC: Pull GITC Manifest Dir from the config. Updates the repo launcher and gitc_utils to pull the manifest directory location out of the gitc config file. Change-Id: Id08381b8a7d61962093d5cddcb3ff6afbb13004b
diff --git a/repo b/repo index bf8fa3d..ff82159 100755 --- a/repo +++ b/repo
@@ -108,7 +108,7 @@ S_manifests = 'manifests' # special manifest repository REPO_MAIN = S_repo + '/main.py' # main script MIN_PYTHON_VERSION = (2, 6) # minimum supported python version -GITC_MANIFEST_DIR = '/usr/local/google/gitc' +GITC_CONFIG_FILE = '/gitc/.config' import errno @@ -222,6 +222,20 @@ dest='gitc_client', help='The name for the new gitc_client instance.') +_gitc_manifest_dir = None +def get_gitc_manifest_dir(): + global _gitc_manifest_dir + if _gitc_manifest_dir is None: + try: + with open(GITC_CONFIG_FILE, 'r') as gitc_config: + for line in gitc_config: + match = re.match('gitc_dir=(?P<gitc_manifest_dir>.*)', line) + if match: + _gitc_manifest_dir = match.group('gitc_manifest_dir') + except IOError: + _gitc_manifest_dir = '' + return _gitc_manifest_dir + class CloneFailure(Exception): """Indicate the remote clone of repo itself failed. """ @@ -255,7 +269,12 @@ try: if gitc_init: - client_dir = os.path.join(GITC_MANIFEST_DIR, opt.gitc_client) + gitc_manifest_dir = get_gitc_manifest_dir() + if not gitc_manifest_dir: + _print('error: GITC filesystem is not running. Exiting...', + file=sys.stderr) + sys.exit(1) + client_dir = os.path.join(gitc_manifest_dir, opt.gitc_client) if not os.path.exists(client_dir): os.makedirs(client_dir) os.chdir(client_dir) @@ -746,6 +765,12 @@ wrapper_path = os.path.abspath(__file__) my_main, my_git = _RunSelf(wrapper_path) + cwd = os.getcwd() + if cwd.startswith(get_gitc_manifest_dir()): + _print('error: repo cannot be used in the GITC local manifest directory.' + '\nIf you want to work on this GITC client please rerun this ' + 'command from the corresponding client under /gitc/', file=sys.stderr) + sys.exit(1) if not repo_main: if opt.help: _Usage()